package com.chengccn.mybatisplus.mytest.contorller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chengccn.mybatisplus.mytest.entity.SysUser;
import com.chengccn.mybatisplus.mytest.mapper.SysUserMapper;
import com.chengccn.mybatisplus.mytest.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author: Administrator
 * @Description:
 * @Date: 2019/5/16 15:29
 * @Version: 1.0
 */
@RestController
public class MyBatisPlusTestController {
    @Autowired
    private SysUserMapper sysUserMapper;

    /**
     * 测试查询所有数据
     *
     * @return 所有数据
     */
    @GetMapping("/")
    public Object getAll() {
        return sysUserMapper.selectList(null);
    }

    /**
     * 查询分页数据
     *
     * @param page 页数
     * @param size 条数
     * @return pageInfo
     */
    @GetMapping("page/{page}/{size}")
    public Object getPage(@PathVariable("page") int page, @PathVariable("size") int size) {
        Page<SysUser> sysUserpage = new Page<SysUser>(page, size);
        IPage<SysUser> iPage = sysUserMapper.selectPage(sysUserpage, null);
        return iPage;
    }
}
